package routers

import (
	"backend/middleware"
	"backend/pkg/logging"
	"backend/pkg/setting"
	"backend/routers/api/v1"
	"github.com/gin-gonic/gin"
	"net/http"
)

func InitRouter() *gin.Engine {
	r := gin.New()

	r.Use(middleware.Cors())

	r.Use(logging.Logger())

	r.Use(gin.Recovery())

	gin.SetMode(setting.ServerSetting.RunMode)

	apiV1 := r.Group("v1")
	{
		apiV1.GET("ping", func(context *gin.Context) {
			context.String(http.StatusOK, "pong")
		})
		apiV1.POST("upload", v1.UploadFile)
		apiV1.GET("picture/:name", v1.GetFile)
	}

	return r
}
